<!--
/*
-->
<!doctype html>
<title>same-origin checks</title>
<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// Needed to prevent a race condition if a worker throws an exception that may or may
// not propogate to the window before the tests finish
setup({allow_uncaught_exception: true});

test(function() {
  assert_throws("SecurityError", function() { new SharedWorker('unsupported:', ''); });
}, "unsupported_scheme");
async_test(function() {
  var worker = new SharedWorker('data:,onconnect = function(e) { e.ports[0].postMessage(1); }', '');
  worker.port.onmessage = this.step_func_done(function(e) {
    assert_equals(e.data, 1);
  });
}, "data_url");
test(function() {
  assert_throws("SecurityError", function() { new SharedWorker('javascript:""', ''); });
}, "javascript_url");
test(function() {
  assert_throws("SecurityError", function() { new SharedWorker('about:blank', ''); });
}, "about_blank");
test(function() {
  assert_throws("SecurityError", function() { new SharedWorker('http://www.opera.com/', ''); });
}, "opera_com");
test(function() {
  assert_throws("SecurityError", function() { new SharedWorker(location.protocol+'//'+location.hostname+':81/', ''); });
}, "port_81");
test(function() {
  assert_throws("SecurityError", function() { new SharedWorker('https://'+location.hostname+':80/', ''); });
}, "https_port_80");
test(function() {
  assert_throws("SecurityError", function() { new SharedWorker('https://'+location.hostname+':8000/', ''); });
}, "https_port_8000");
test(function() {
  assert_throws("SecurityError", function() { new SharedWorker('http://'+location.hostname+':8012/', ''); });
}, "http_port_8012");
</script>
<!--
*/
//-->
